<template>
  <div>
    <div>
      <el-form ref="form" :model="job" label-width="80px">
        <el-form-item label="公司名"><el-input v-model="job.name" @input="updateView"></el-input></el-form-item>
        <el-form-item label="职位"><el-input v-model="job.position" @input="updateView"></el-input></el-form-item>
        <el-form-item label="专业"><el-input v-model="job.major" @input="updateView"></el-input></el-form-item>
        <el-form-item label="数量"><el-input v-model="job.number" @input="updateView"></el-input></el-form-item>
      </el-form>
    </div>
    <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirm">确 定</el-button>
      </span>
  </div>
</template>

<script>
  export default {
    name: "addTeam",
    data(){
      return {};
    },
    methods:{
      //添加
      addUser(){
        if(!this.userInfo.name){
          this.$message({
            message: '请输入你的公司名！',

          });
          return;
        }
        if(!this.userInfo.position){
          this.$message({
            message: '请输入你的职位！',
            type: 'warning'
          });
          return;
        }
        if (!this.userInfo.major) {
          this.$message({
            message: '请输入你的专业！',
            type: 'warning'
          });
          return;
        }
        if (!this.userInfo.number) {
          this.$message({
            message: '请输入数量！',
            type: 'warning'
          });
          return;
        }
        this.tableData.push(this.userInfo);
        this.userInfo = {
          name:'',
          position: '',
          major: '',
          number: '',
        };
      },

      //删除
      delUser(idx){
        this.$confirm('确认删除此用户信息？')
          .then(_ => {
            this.tableData.splice(idx, 1);
          })
          .catch(_ => {});
      },

      updateView(e) {
        this.$forceUpdate()
      },

      confirm(){
        // Vue.set(this.tableData, this.userIndex, this.editObj);
        console.log(this.job);
      }
    },
    //编辑
    created:function () {
      console.log(this);
      this.job = {
        name: "",
        position: "",
        major: "",
        number: 0,
      };
    }
  }
</script>

<style scoped>

</style>
